#ifndef BSPENT_H_
#define BSPENT_H_

#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <map>
#include <list>

#include "Exception.h"

#include "irrlicht.h"

class BspEnt
{
	protected:
	std::list<std::map<std::string, std::string> > nodes__;

	bool check_magic(std::ifstream& is);
	std::pair<int, int> entities_info(std::ifstream& is);
	void get_nodes(const std::pair<int, int>& ent_info, std::ifstream& is);
	void parse(std::stringstream& ss);
	std::pair<bool, std::map<std::string, std::string> > parse_acc(std::stringstream& ss);
	bool parse_str(std::stringstream& ss, std::string& s);

	public:
	BspEnt();
	virtual ~BspEnt();

	void load(const std::string& map);
	std::list<std::map<std::string, std::string> >& getNodes();

};

// Just take a string composed of 3 floatting numbers separates by spaces, and returns them as a vector3df from Irrlicht
irr::core::vector3df strToVector3df(const std::string& s);
// Same function as above, but swap Z and Y axis; due to BSP format
irr::core::vector3df bspStrToVector3df(const std::string& s);
int strToInt(const std::string& s);
double strToDouble(const std::string& s);

#endif

